<template>
  <div>
    <el-card>
      <el-page-header @back="goBack"> </el-page-header>
    </el-card>
    <br>
    <el-card>
      <div slot="header" class="clearfix">
        <span>订单详细</span>
      </div>
      <el-form :model="form">
        <div class="Order_Details_style">
          <el-form-item> 订单编号: {{ form.orderNumber }} </el-form-item>
          <el-form-item> 付款时间: {{ form.payTime }} </el-form-item>
        </div>
        <el-card>
          <div slot="header" class="">
            <span>收货人信息</span>
          </div>
          <div class="">
            <el-form-item label="收货人姓名:">
              {{ form.recipients }}
            </el-form-item>
            <el-form-item label="收货人电话:">
              {{ form.telephone }}
            </el-form-item>
            <el-form-item label="收货人地址:">
              {{ form.address }}
            </el-form-item>
          </div>
        </el-card>
      </el-form>
      <br />
    
      <el-form>
        <el-card>
          <div slot="header" class="Order-information">
            <span>产品信息</span>
          </div>
          <div class="">
            <el-row type="flex" class="row-bg" :model="store" v-for="item in store" :key="item.id">
              <el-form-item>
                <h1><img :src="loaclhostPath+item.commodityPicturePath" alt="" style="width: 120px;heigth:100px"></h1>
              </el-form-item>
              <el-col :span="22" style=" margin-left:2rem ;">
                <el-form-item>
                  {{item.commodityName }}
                </el-form-item>
                <el-form-item>
                  规格: {{ item.speChildId }}
                  &nbsp; &nbsp; &nbsp; &nbsp;
                  数量: {{ item.comnum }}
                </el-form-item>
                <el-form-item style="color:red;" label="价格:">
                 ${{item.price}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
         <el-card style="height:4rem">
             <div class="Order-foot">
                 <label for="">总数：{{totalNumber}} </label>
                 <label for="">总价：{{totalPrice}} 元</label>
             </div>
         </el-card>
        </el-card>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import common from "../../utils/common";
import {getOrderDetailsLists} from '../../api/ord'
export default {
  data() {
    return {
      loaclhostPath: common.localhostPath,
      form: {
      
      },
      store: [],
    };
  },
     created() {
    this.getOrderDetailList();
  },
  computed: {
    // 总价
    totalPrice() {
      var commodity = this.store;
      var price_total = 0;
      for (var i = 0; i < commodity.length; i++) {
        price_total +=
          commodity[i].orderPrice * commodity[i].comnum;
      }
      return price_total;
    },
     // 总数
    totalNumber() {
      var commodity =this.store;
      var number_total = 0;
      for (var i = 0; i < commodity.length; i++) {
        number_total += commodity[i].comnum;
      }
      return number_total;
    },

  },
  methods: {
      getOrderDetailList(){
      var orderNum=localStorage.getItem("orderNum");
        getOrderDetailsLists(orderNum).then(({data})=>{
        console.log(data);
        this.form=data.data[0];
      this.store=data.data;

      }).catch((err) => {
          console.log(err);
        });
    },
    goBack() {
        this.$router.go(-1)
    },
  },
};
</script>

<style scoped>
.Order_Details_style {
  display: flex;
  justify-content: space-between;
}
.Order-foot{
    float: right;
}
</style>